<template>
  <div></div>
</template>

<script name="queryRedirect" setup>
import { useRoute, useRouter } from 'vue-router'

const route = useRoute();
const router = useRouter();
const { params, query } = route

const paramsObject = {};

for (const key in query) {
  if (query.hasOwnProperty(key)) {
    try {
      let value = query[key]; // 修正此处使用 query[key]
      // 尝试解码 URL 编码
      value = decodeURIComponent(value);
      // 尝试解析每个值为 JSON，如果失败则保持原始值
      paramsObject[key] = JSON.parse(value);
    } catch (error) {
      // 解析失败，保持原始字符串
      paramsObject[key] = query[key];
    }
  }
}

const tableForm = Object.assign({}, paramsObject)
delete tableForm.path

sessionStorage.setItem('_table_form', JSON.stringify({ tableForm }))
router.replace(query.path)

</script>